#!/usr/bin/env node
import { Dog } from './05-dog.js';

// 实例化 Dog 对象
const dog1 = new Dog('Buddy', 3);
const dog2 = new Dog('Max', 5);
const dog3 = new Dog('Charlie', 2);

// 事件处理函数
const barkHandler = (name, energy) => {
  console.log(`${name} barked! Energy left: ${energy}`);
};

// 注册事件
dog1.on('bark', barkHandler);
dog2.on('bark', barkHandler);
dog3.on('bark', barkHandler);

// 测试程序
console.log('Dogs are barking...');